package com.jtny.nytb.config.datafactor.service;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jtny.component.exception.ServiceException;
import com.jtny.nytb.config.datafactor.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 设备数据参量接口
 *
 * @author 智慧能源中心 - 伍天宇
 * @package com.jtny.nytb.config.datafactor.service
 * @fileName DataParamEquipmentExtendService.java
 * @createTime 2023年11月15日 20:18
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Api(value = "设备数据参量接口", tags = "设备数据参量接口")
@ResponseBody
public interface DataParamEquipmentExtendService {

    /**
     * 导入数据参数设备扩展
     *
     * @param equipmentModelDataParamDTO 设备型号数据参数 DTO
     * @throws ServiceException 服务异常
     */
    @PostMapping("/import-data-param-equipment-extend")
    void importDataParamEquipmentExtend(@RequestBody EquipmentModelDataParamDTO equipmentModelDataParamDTO) throws ServiceException;

    @PostMapping("/save-data-param-equipment-extend-batch")
    Boolean saveDataParamEquipmentExtendBatch(@RequestBody List<DataParam4EquipmentDTO> dataParam4EquipmentList) throws ServiceException;

    @PostMapping("/update-data-param-equipment-extend-batch")
    Boolean updateDataParamEquipmentExtendBatch(@RequestBody List<DataParam4EquipmentDTO> dataParam4EquipmentList) throws ServiceException;

    /**
     * 更新设备数据参数状态
     *
     * @param equipmentId 设备 ID
     * @param status      地位
     * @throws ServiceException 服务异常
     */
    @PostMapping("/update-data-param-status/{equipmentId}/{status}")
    void updateEquipmentDataParamStatus(@PathVariable("equipmentId") Long equipmentId, @RequestParam("status") Integer status) throws ServiceException;

    /**
     * 更新数据参数名称
     *
     * @param equipmentId   设备 ID
     * @param equipmentName 设备名称
     * @return {@link Boolean}
     */
    @PostMapping("/update-data-param-name/{equipmentId}/{equipmentName}")
    Boolean updateDataParamName(@PathVariable("equipmentId") Long equipmentId, @PathVariable("equipmentName") String equipmentName);
    /**
     * 获取设备数据参数list
     *
     * @param dataParamId 参量id
     * @return {@link List}<{@link DataParam4EquipmentDTO}> 设备数据参数列表
     */
    @GetMapping("/get-data-param-id/{dataParamId}")
    DataParam4EquipmentDTO getDataParam4EquipmentByDataParamId(@PathVariable("dataParamId") Long dataParamId) throws ServiceException;
    /**
     * 获取设备数据参数list
     *
     * @param equipmentId 设备id
     * @return {@link List}<{@link DataParam4EquipmentDTO}> 设备数据参数列表
     */
    @GetMapping("/list-data-param-equipment-id/{equipmentId}")
    List<DataParam4EquipmentDTO> listDataParamByEquipmentId(@PathVariable("equipmentId") Long equipmentId) throws ServiceException;

    /**
     * 按设备代码列出数据参数
     *
     * @param equipmentCode 设备代码
     * @return {@link List}<{@link DataParam4EquipmentDTO}>
     * @throws ServiceException 服务异常
     */
    @GetMapping("/list-data-paramby-equipmentCode/{equipmentCode}")
    List<DataParam4EquipmentDTO> listDataParamByEquipmentCode(@PathVariable("equipmentCode") String equipmentCode) throws ServiceException;

    /**
     * 列出数据参数 ID 关系
     *
     * @param equipmentId 设备id
     * @return {@link List}<{@link Long}> 数据参量 ID 列表
     */
    @GetMapping("/list-data-paramId/{equipmentId}")
    List<Long> listDataParamIdRelation(@PathVariable("equipmentId") Long equipmentId) throws ServiceException;

    /**
     * 按设备 ID 列出数据参数扩展
     *
     * @param equipmentId 设备 ID
     * @return {@link List}<{@link DataParam4EquipmentExtendDTO}>
     * @throws ServiceException 服务异常
     */
    @GetMapping("/list-data-param-extend-equipment-id/{equipmentId}")
    List<DataParam4EquipmentExtendDTO> listDataParamExtendByEquipmentId(@PathVariable("equipmentId") Long equipmentId) throws ServiceException;


    /**
     * 列出数据参数 code
     *
     * @param equipmentCode 设备code
     * @return {@link List}<{@link Long}> 数据参量 ID 列表
     */
    @GetMapping("/list-data-param-code/{equipmentCode}")
    List<String> listDataParamCodeRelation(@PathVariable("equipmentCode") String equipmentCode) throws ServiceException;

    /**
     * 保存关系设备数据参数
     *
     * @param equipmentDataParamRelationDTO 关系设备数据参数 DTO
     * @return {@link Boolean}
     * @throws ServiceException 服务异常
     */
    @PostMapping("/save-relation-equipment-data-param")
    Boolean saveRelationEquipmentDataParam(@RequestBody EquipmentDataParamRelationDTO equipmentDataParamRelationDTO) throws ServiceException;

    /**
     * 保存批次关系设备数据参数
     *
     * @param dataParamCoreList 数据参数核心列表
     * @return {@link Boolean}
     * @throws ServiceException 服务异常
     */
    @PostMapping("/save-batch-relation-equipment-data-param")
    Boolean saveBatchRelationEquipmentDataParam(@RequestBody List<DataParamCoreDTO> dataParamCoreList) throws ServiceException;

    /**
     * 保存 Sing Relation Equipment 数据参数
     *
     * @param equipmentDataParamDTO 设备数据参数 DTO
     * @return {@link Boolean}
     * @throws ServiceException 服务异常
     */
    @PostMapping("/save-sing-relation-equipment-data-param")
    Boolean saveSingRelationEquipmentDataParam(@RequestBody EquipmentDataParamDTO equipmentDataParamDTO) throws ServiceException;

    /**
     * 通过数据参数 ID 获取关系设备数据参数
     *
     * @param dataParamId 数据参数 ID
     * @return {@link EquipmentDataParamDTO}
     * @throws ServiceException 服务异常
     */
    @GetMapping("/get-relation-equipment-data-param-data-param-id/{dataParamId}")
    EquipmentDataParamDTO getRelationEquipmentDataParamByDataParamId(@PathVariable("dataParamId") Long dataParamId) throws ServiceException;

    /**
     * 按数据参数 ID 映射标识符
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link Map}<{@link Long}, {@link String}>
     * @throws ServiceException 服务异常
     */
    @PostMapping("/map-identifier-data-param-ids")
    Map<Long, String> mapIdentifierByDataParamIds(@RequestBody List<Long> dataParamIds) throws ServiceException;

    /**
     * 按数据参数 ID 列表查询设备数据参数关系
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link Map}<{@link String}, {@link EquipmentDataParamExtendDTO}> key: dataParamIds
     */
    @PostMapping("/map-code-extend-data-param-ids")
    Map<String, EquipmentDataParamExtendDTO> mapCodeExtendByDataParamIds(@RequestBody List<Long> dataParamIds) throws ServiceException;

    /**
     * 按设备 ID 列表查询数据参数 ID 列表
     *
     * @param equipmentIdList 设备 ID 列表
     * @return {@link List}<{@link Long}> 数据参数 ID 列表
     * @throws ServiceException 服务异常
     */
    @PostMapping("/listDataParamIdByEquipmentIds")
    List<Long> listDataParamIdByEquipmentIds(@RequestBody List<Long> equipmentIdList) throws ServiceException;

    /**
     * 映射设备 ID 数据参数列表
     *
     * @param equipmentIdList 设备 ID 列表
     * @return {@link Map}<{@link Long}, {@link List}<{@link String}>>
     * @throws ServiceException 服务异常
     */
    @PostMapping("/mapEquipmentIdDataParamList")
    Map<Long, List<String>> mapEquipmentIdDataParamList(@RequestBody List<Long> equipmentIdList) throws ServiceException;

    /**
     * 映射设备 ID 数据参数 ID 列表
     *
     * @param equipmentIdList 设备 ID 列表
     * @return {@link Map}<{@link Long}, {@link List}<{@link Long}>> key: equipmentId, value: dataParamIdList
     * @throws ServiceException 服务异常
     */
    @PostMapping("/mapEquipmentIdDataParamIdList")
    Map<Long, List<Long>> mapEquipmentIdDataParamIdList(@RequestBody List<Long> equipmentIdList) throws ServiceException;

    /**
     * 删除数据参数关系
     *
     * @param dataParamIds 数据参数 ID
     */
    @PostMapping("/deleteDataParamRelation")
    void deleteDataParamRelation(@RequestBody List<Long> dataParamIds) throws ServiceException;

    /**
     * 按设备 ID 删除
     *
     * @param equipmentIdList 设备 ID 列表
     * @throws ServiceException 服务异常
     */
    @PostMapping("/delete-equipment-ids")
    void deleteByEquipmentIds(@RequestBody List<Long> equipmentIdList) throws ServiceException;


    /**
     * 按数据参数设备 ID 删除
     *
     * @param equipmentIdList 设备 ID 列表
     * @throws ServiceException 服务异常
     */
    @PostMapping("/delete-data-param-equipment-ids")
    void deleteByDataParamEquipmentIds(@RequestBody List<Long> equipmentIdList) throws ServiceException;

    /**
     * 获取设备关联参量Code，通过设备参量上报标识和设备Code
     *
     * @param equipmentCode        设备Code
     * @param reportIdentifierList 设备上报标识
     * @return {@link List}<{@link String}> 设备关联参量Code
     */
    @PostMapping("/mapDataParamCodeByReportIdentifierAndEquipmentCode/{equipmentCode}")
    Map<String, String> mapDataParamCodeByReportIdentifierAndEquipmentCode(@PathVariable("equipmentCode") String equipmentCode,
                                                                           List<String> reportIdentifierList)
            throws ServiceException;

    /**
     * 按数据参数 ID 映射设备 ID
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link Map}<{@link Long}, {@link Long}> key: dataParamId, value: equipmentId
     * @throws ServiceException 服务异常
     */
    @PostMapping("/mapEquipmentIdByDataParamIds")
    Map<Long, Long> mapEquipmentIdByDataParamIds(@RequestBody List<Long> dataParamIds)
            throws ServiceException;


    /**
     * 按数据参数 ID 列表查询设备数据参数关系
     *
     * @param dataParamIds 数据参数 ID
     * @return {@link Map}<{@link Long}, {@link EquipmentDataParamExtendDTO}> key: dataParamId
     */
    @PostMapping("/mapExtendByDataParamIds")
    Map<Long, DataParam4EquipmentExtendDTO> mapExtendByDataParamIds(@RequestBody List<Long> dataParamIds) throws ServiceException;

//    /**
//     * 添加设备标签列表
//     *
//     * @param equipmentId 设备 ID
//     * @param labelIdList 标签 ID 列表
//     * @throws ServiceException 服务异常
//     */
//    @PostMapping("/add-data-param-label-list/{equipmentId}")
//    void addDataParamLabelList(@PathVariable("equipmentId") Long equipmentId, @RequestBody List<ConfigLabelDTO> labelIdList) throws ServiceException;

//    /**
//     * 删除设备标签列表
//     *
//     * @param equipmentId 设备 ID
//     * @param labelIdList 标签 ID 列表
//     * @throws ServiceException 服务异常
//     */
//    @PostMapping("/delete-data-param-label-list/{equipmentId}")
//    void deleteDataParamLabelList(@PathVariable("equipmentId") Long equipmentId, @RequestBody List<Long> labelIdList) throws ServiceException;

    @ApiOperation("生成一条新编码")
    @ApiImplicitParams({@ApiImplicitParam(
            name = "code",
            value = "编号规则code",
            required = true,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "superiorCode",
            value = "父节点",
            required = true,
            paramType = "query"
    )})
    @ApiOperationSupport(
            order = 8
    )
    @RequestMapping({"/queryCodeBycode"})
    @ResponseBody
    public String queryCodeBycode(@RequestParam(value = "code",required = false) String var1, @RequestParam(value = "superiorCode",required = false) String var2);
}
